home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / math / maca_101.zip / ASSIGN.DEM < prev    next >
Text File  |  1996-01-30  |  3KB  |  107 lines

  1. ;ASSIGN.DEM
  2. ;DEMO FILE FOR MASSCALC VERSION 1.00
  3. ;WRITTEN BY: Ralph W. Reid
  4. ;This file may only be distributed in its unmodified form.
  5. ;
  6. ;DESCRIPTION:  This file primarily demonstrates value assignments.
  7. ;
  8. ;For the latest releases of MASSCALC and other software created by
  9. ;Ralph W. Reid, see http://www2.athenon.com/~rreid/products/00-index.html.
  10. ;
  11. ;HOW TO USE THIS FILE:  This file may be piped into MASSCALC, and its
  12. ;output displayed as follows:
  13. ;TYPE ASSIGN.DEM | MASSCALC | MORE
  14. ;This file may be redirected into MASSCALC and its output displayed
  15. ;as follows:
  16. ;MASSCALC < ASSIGN.DEM | MORE
  17. ;These two commands should be run from the operating system prompt.
  18.  
  19. ;single element assignments (variable need not be dimensioned)
  20. var1 = 8;
  21. var2 = sin (_pi_2);
  22. var3 = 5 * 100 / log (1e5) / log_b (2, 4) - 49 * sqrt (2);
  23. var4 = root_secant (x, 1, 2, x - sqrt (2));
  24. print: "var1 =" var1
  25. print: "var2 =" var2
  26. print: "var3 =" var3
  27. print: "var4 =" var4
  28.  
  29. ;assign individual array elements one by one
  30. create array: vars [4];
  31. vars [1] = 8;
  32. vars [2] = sin (_pi_2);
  33. vars [3] = 5 * 100 / log (1e5) / log_b (2, 4) - 49 * sqrt (2);
  34. vars [4] = root_secant (x, 1, 2, x - sqrt (2));
  35. print: "vars [1] =" vars [1]
  36. print: "vars [2] =" vars [2]
  37. print: "vars [3] =" vars [3]
  38. print: "vars [4] =" vars [4]
  39. print: "complete vars array:"
  40. vars;
  41.  
  42. ;assign all array elements in one line
  43. vars = 2, 4, 6, 8;
  44. print:
  45. print: "After single line assignment, vars:"
  46. vars;
  47.  
  48. ;use the array to assign new values to itself
  49. vars = vars / 2;
  50. print:
  51. print: "After vars = vars / 2, vars:"
  52. vars;
  53.  
  54. ;show lists of derivatives
  55. create array: y [1, 5];
  56. create array: y' [1, 5];
  57. create array: y'' [1, 5];
  58. create array: y''' [1, 5];
  59. print:
  60. print: "Using lists to assign derivatives to other lists:"
  61. ;start with values from x^2 spaced at an interval of 1
  62. y = 0, 1, 4, 9, 16;
  63. y' = derive_list (1, y);
  64. y'' = derive_list (1, y');
  65. y''' = derive_list (1, y'');
  66. ;output the results
  67. print: "y, y', y'', and y''':" y, y', y'', y'''
  68.  
  69. ;put these result arrays into a single array
  70. create array: totals [4, 5];
  71. totals = y, y', y'', y''';
  72. print:
  73. print: "After putting all values into a single array, totals:" totals
  74.  
  75. ;zero out the first row, element by element
  76. totals [1, 1] = 0.0;
  77. totals [1, 2] = 0.0;
  78. totals [1, 3] = 0.0;
  79. totals [1, 4] = 0.0;
  80. totals [1, 5] = 0.0;
  81. print:
  82. print: "After clearing the first row, totals equals:" totals
  83.  
  84. ;assign values to totals directly from equations
  85. y = 1, 2, 3, 4, 5;
  86. totals = y, 2*y, 3*y, 4*y;
  87. print:
  88. print: "After assignment directly from equations, totals equals:"
  89. totals;
  90.  
  91. ;clear old variables and arrays from memory
  92. Delete all variables.
  93.  
  94. ;assign an array values from a function
  95. create array: pi values [2, 2];
  96. create array: sin pi values [2, 2];
  97. create array: cos pi values [2, 2];
  98. ;assign multiples of pi to pi array
  99. pi values = 0, _pi / 2, _pi, 3 * _pi / 2;
  100. ;assign function values to their respective arrays
  101. sin pi values = sin (pi values);
  102. cos pi values = cos (pi values);
  103. ;output results
  104. print:
  105. print: "pi vals, sines, & cosines:" pi values, sin pi values, cos pi values
  106.  
  107.